<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var obj1={
            name:"tom",
            age:20,
            sex:"女"
        };
        var obj2={
            sex:"男",
            weight:130,
            show:function(){
                console.log("我正在学习");
            }
        };
        var obj3={
            hobby:"嘻嘻嘻"
        };
        //组合式继承
        // for(var key in obj1){
        //     // console.log(obj1[key]);//对应的obj1的属性值
        //     obj2[key]=obj1[key];//obj2["name"]="tom"   obj2["age"]=20 obj2["sex"]="女"
        // }
        // console.log(obj2);

        obj2.extend=function(obj){
            for(var key in obj){
                obj2[key]=obj[key]
            }
        };
        obj2.extend(obj1);
        obj2.extend(obj3);

        console.log(obj2);


    </script>
</head>
<body>
    
</body>
</html>